﻿@model dynamic
@using Contrib.Chapters.Models;
@using Contrib.Chapters.ViewModels;

@{
	Style.Include("chapters.css");
	int chapterIndex = 0, ti;
}

<h1>@Html.TitleForPage(T("Manage vocabulary for {0}", (string)Model.Book.Name).ToString())</h1>
@using(Html.BeginFormAntiForgeryPost()) {
	@Html.ValidationSummary()
	<div class="manage">@Html.ActionLink(T("Add a Chapter").ToString(), "SelectChapter", new { bookId = Model.Book.Id }, new { @class = "button primaryAction" })</div>
	<fieldset>
		<table class="items" summary="@T("This is a table of the chapters in this book")">
			<colgroup>
				<col id="Col1" />
				<col id="Col2" />
			</colgroup>
			<thead>
				<tr>
					<th scope="col">@T("Name")</th>
					<th scope="col"></th>
				</tr>
			</thead>
				@foreach (ChapterPart chapter in Model.Chapters) {
					ti = chapterIndex;
			<tr>
				<td>
					@* Tabs for levels *@ @for ( var i = 1; i <= chapter.Level; i++ ) { <span class="gap">&nbsp;</span> }
					@Html.ItemDisplayLink(chapter.Title, chapter.ContentItem)
				</td>
				<td>
				@Html.ActionLink(T("Properties").ToString(), "Edit", new { id = chapter.Id }) |
				@Html.ActionLink(T("Move").ToString(), "MoveChapter", new { bookId = Model.Book.Id, chapterId = chapter.Id })
				</td>
			</tr>
				chapterIndex++;
			}
		</table>
	</fieldset>
}